Update log crate to v0.2
authorGabriel Souza Franco <gabrielfrancosouza@gmail.com>
Fri, 30 Jan 2015 14:36:24 +0000 (12:36 -0200)
committerGabriel Souza Franco <gabrielfrancosouza@gmail.com>
Fri, 30 Jan 2015 18:08:04 +0000 (16:08 -0200)
15 files changed:
Cargo.lock
Cargo.toml
src/bin/cargo.rs
src/cargo/core/registry.rs
src/cargo/core/resolver/mod.rs
src/cargo/core/source.rs
src/cargo/lib.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/ops/cargo_rustc/fingerprint.rs
src/cargo/ops/cargo_rustc/job_queue.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/sources/git/source.rs
src/cargo/sources/path.rs
src/cargo/sources/registry.rs

index e637c168f69414122bea1db73e64e1988ee53734..f722770d3396b56730cf1545e9d0a90b9314ab43 100644 (file)
@@ -5,11 +5,12 @@ dependencies = [
  "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "docopt 0.6.31 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "flate2 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "git2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "glob 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
- "log 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "registry 0.1.0",
  "rustc-serialize 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -65,6 +66,15 @@ dependencies = [
  "rustc-serialize 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "env_logger"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "log 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "flate2"
 version = "0.1.6"
@@ -156,6 +166,11 @@ dependencies = [
  "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "log"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "matches"
 version = "0.1.2"
index bf595de89489bddacc8b5d33a236c238bc5d0ee9..e691eddd05a802231bd3ef37407b57750706aed8 100644 (file)
@@ -18,7 +18,8 @@ flate2 = "0.1"
 git2 = "0.1"
 glob = "0.1"
 time = "0.1"
-log = "0.1"
+log = "0.2"
+env_logger = "0.2"
 docopt = "0.6"
 url = "0.2"
 rustc-serialize = "0.2"
index f39b6d008b8780834ab50df4c586d99a9c88d104..83dfaecd2014d27c24e9696922c3675f37029aa9 100644 (file)
@@ -3,6 +3,7 @@
 extern crate "rustc-serialize" as rustc_serialize;
 extern crate cargo;
 #[macro_use] extern crate log;
+extern crate env_logger;
 
 use std::collections::BTreeSet;
 use std::os;
@@ -49,6 +50,7 @@ See 'cargo help <command>' for more information on a specific command.
 ";
 
 fn main() {
+    env_logger::init().unwrap();
     execute_main_without_stdin(execute, true, USAGE)
 }
 
index 281e097f75834395a1014b2270a0a81c3003a945..0a9c0c96b890d5c2d2380d5da36f3333ae7800de 100644 (file)
@@ -80,7 +80,7 @@ impl<'a, 'b> PackageRegistry<'a, 'b> {
     }
 
     pub fn get(&mut self, package_ids: &[PackageId]) -> CargoResult<Vec<Package>> {
-        log!(5, "getting packages; sources={}", self.sources.len());
+        trace!("getting packages; sources={}", self.sources.len());
 
         // TODO: Only call source with package ID if the package came from the
         // source
index 10c81338e9efaf65057085f9daa693e8438e9193..223afa784054d9b97a6ce30486e05c0b1728dd30 100644 (file)
@@ -131,7 +131,7 @@ struct Context {
 /// Builds the list of all packages required to build the first argument.
 pub fn resolve(summary: &Summary, method: Method,
                registry: &mut Registry) -> CargoResult<Resolve> {
-    log!(5, "resolve; summary={}", summary.get_package_id());
+    trace!("resolve; summary={}", summary.get_package_id());
     let summary = Rc::new(summary.clone());
 
     let cx = Box::new(Context {
@@ -251,9 +251,9 @@ fn activate_deps<'a>(cx: Box<Context>,
     let key = (dep.get_name().to_string(), dep.get_source_id().clone());
     let prev_active = cx.activations.get(&key)
                                     .map(|v| v.as_slice()).unwrap_or(&[]);
-    log!(5, "{}[{}]>{} {} candidates", parent.get_name(), cur, dep.get_name(),
+    trace!("{}[{}]>{} {} candidates", parent.get_name(), cur, dep.get_name(),
          candidates.len());
-    log!(5, "{}[{}]>{} {} prev activations", parent.get_name(), cur,
+    trace!("{}[{}]>{} {} prev activations", parent.get_name(), cur,
          dep.get_name(), prev_active.len());
 
     // Filter the set of candidates based on the previously activated
@@ -283,7 +283,7 @@ fn activate_deps<'a>(cx: Box<Context>,
     // each one in turn.
     let mut last_err = None;
     for candidate in my_candidates {
-        log!(5, "{}[{}]>{} trying {}", parent.get_name(), cur, dep.get_name(),
+        trace!("{}[{}]>{} trying {}", parent.get_name(), cur, dep.get_name(),
              candidate.get_version());
         let mut my_cx = cx.clone();
         my_cx.resolve.graph.link(parent.get_package_id().clone(),
@@ -304,7 +304,7 @@ fn activate_deps<'a>(cx: Box<Context>,
             Err(e) => { last_err = Some(e); }
         }
     }
-    log!(5, "{}[{}]>{} -- {:?}", parent.get_name(), cur, dep.get_name(),
+    trace!("{}[{}]>{} -- {:?}", parent.get_name(), cur, dep.get_name(),
          last_err);
 
     // Oh well, we couldn't activate any of the candidates, so we just can't
index b7c1c02a0edf33478c633382ac4d5a57211356f9..089a38890a4b91259135d3da8be5172113d53eee 100644 (file)
@@ -193,7 +193,7 @@ impl SourceId {
 
     /// Creates an implementation of `Source` corresponding to this ID.
     pub fn load<'a>(&self, config: &'a Config) -> Box<Source+'a> {
-        log!(5, "loading SourceId; {}", self);
+        trace!("loading SourceId; {}", self);
         match self.inner.kind {
             Kind::Git(..) => Box::new(GitSource::new(self, config)) as Box<Source>,
             Kind::Path => {
index 6875c41c0bcb0fc5d3e4cb6afafd6b630c399115..895200b06c18f852659efb3ea112c3038bcb1e18 100644 (file)
@@ -141,7 +141,7 @@ fn output(err: String, shell: &mut MultiShell, fatal: bool) {
 }
 
 pub fn handle_error(err: CliError, shell: &mut MultiShell) {
-    log!(4, "handle_error; err={:?}", err);
+    debug!("handle_error; err={:?}", err);
 
     let CliError { error, exit_code, unknown } = err;
     let fatal = exit_code != 0; // exit_code == 0 is non-fatal error
index 857c2094a50e2e0e2554c96fd3d40cf99aeb7f16..a0fea0f37fb1a65ece184a51895ff9dbc8ff23c7 100644 (file)
@@ -56,7 +56,7 @@ pub struct CompileOptions<'a, 'b: 'a> {
 pub fn compile(manifest_path: &Path,
                options: &CompileOptions)
                -> CargoResult<ops::Compilation> {
-    log!(4, "compile; manifest-path={}", manifest_path.display());
+    debug!("compile; manifest-path={}", manifest_path.display());
 
     let mut source = try!(PathSource::for_path(&manifest_path.dir_path(),
                                                options.config));
index 7bfefa0959838c3dc266ccf10330ab1f80918ef3..27c8c42aa1d74a2aa7ed929d352ec0646d550449 100644 (file)
@@ -20,7 +20,7 @@ pub fn read_manifest(contents: &[u8], layout: Layout, source_id: &SourceId,
 
 pub fn read_package(path: &Path, source_id: &SourceId, config: &Config)
                     -> CargoResult<(Package, Vec<Path>)> {
-    log!(5, "read_package; path={}; source-id={}", path.display(), source_id);
+    trace!("read_package; path={}; source-id={}", path.display(), source_id);
     let mut file = try!(File::open(path));
     let data = try!(file.read_to_end());
 
@@ -36,10 +36,10 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
     let mut all_packages = HashSet::new();
     let mut visited = HashSet::<Path>::new();
 
-    log!(5, "looking for root package: {}, source_id={}", path.display(), source_id);
+    trace!("looking for root package: {}, source_id={}", path.display(), source_id);
 
     try!(walk(path, |dir| {
-        log!(5, "looking for child package: {}", dir.display());
+        trace!("looking for child package: {}", dir.display());
 
         // Don't recurse into git databases
         if dir.filename_str() == Some(".git") { return Ok(false); }
@@ -78,7 +78,7 @@ fn walk_inner<F>(path: &Path, callback: &mut F) -> CargoResult<()>
     if path.is_dir() {
         let continues = try!(callback(path));
         if !continues {
-            log!(5, "not processing {}", path.display());
+            trace!("not processing {}", path.display());
             return Ok(());
         }
 
index 96d8ed99de9cb248899dae411e5d8ee96aad3fc5..297173a31a3f9e48f2b55af1f48a1abcbefbb87d 100644 (file)
@@ -322,8 +322,8 @@ fn is_fresh(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult<bool> {
         Err(..) => return Ok(false),
     };
 
-    log!(5, "old fingerprint: {}", old_fingerprint);
-    log!(5, "new fingerprint: {}", new_fingerprint);
+    trace!("old fingerprint: {}", old_fingerprint);
+    trace!("new fingerprint: {}", new_fingerprint);
 
     Ok(old_fingerprint.as_slice() == new_fingerprint)
 }
index 9e09e73efcc8c13174f9ae888c47a0a9fa959511..65e37661d25ee84f8bca8d9de6f9ea9205201574 100644 (file)
@@ -151,7 +151,7 @@ impl<'a, 'b> JobQueue<'a, 'b> {
             }
         }
 
-        log!(5, "rustc jobs completed");
+        trace!("rustc jobs completed");
 
         Ok(())
     }
index bc91c325bf1815fc75fb12d37f9364da541c53bd..f5a2a16bbb74ca06dfd22718dc29ed47375491c0 100644 (file)
@@ -528,7 +528,7 @@ fn rustdoc(package: &Package, target: &Target,
         None
     });
 
-    log!(5, "commands={}", rustdoc);
+    trace!("commands={}", rustdoc);
 
     let primary = package.get_package_id() == cx.resolve.root();
     let name = package.get_name().to_string();
index 405590dea8347c48d845838a6c6b05b93aa213ae..24470e59113b71938551e3c369c8e567db6f8eb0 100644 (file)
@@ -172,7 +172,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> {
             try!(self.config.shell().status("Updating",
                 format!("git repository `{}`", self.remote.get_url())));
 
-            log!(5, "updating git source `{:?}`", self.remote);
+            trace!("updating git source `{:?}`", self.remote);
             let repo = try!(self.remote.checkout(&self.db_path));
             let rev = try!(repo.rev_for(&self.reference));
             (repo, rev)
@@ -197,7 +197,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> {
     }
 
     fn get(&self, ids: &[PackageId]) -> CargoResult<Vec<Package>> {
-        log!(5, "getting packages for package ids `{:?}` from `{:?}`", ids,
+        trace!("getting packages for package ids `{:?}` from `{:?}`", ids,
              self.remote);
         self.path_source.as_ref().expect("BUG: update() must be called \
                                           before get()").get(ids)
index ff1538d435459d2ef0486bb3fcdfe8221517312f..a8ef8b5c920802298e56753f7705b46e7f5666ac 100644 (file)
@@ -21,7 +21,7 @@ pub struct PathSource<'a, 'b: 'a> {
 impl<'a, 'b> PathSource<'a, 'b> {
     pub fn for_path(path: &Path, config: &'a Config<'b>)
                     -> CargoResult<PathSource<'a, 'b>> {
-        log!(5, "PathSource::for_path; path={}", path.display());
+        trace!("PathSource::for_path; path={}", path.display());
         Ok(PathSource::new(path, &try!(SourceId::for_path(path)), config))
     }
 
@@ -30,7 +30,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
     /// in the directory structure reachable by the root manifest.
     pub fn new(path: &Path, id: &SourceId, config: &'a Config<'b>)
                -> PathSource<'a, 'b> {
-        log!(5, "new; id={}", id);
+        trace!("new; id={}", id);
 
         PathSource {
             id: id.clone(),
@@ -42,7 +42,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
     }
 
     pub fn get_root_package(&self) -> CargoResult<Package> {
-        log!(5, "get_root_package; source={:?}", self);
+        trace!("get_root_package; source={:?}", self);
 
         if !self.updated {
             return Err(internal("source has not been updated"))
@@ -239,7 +239,7 @@ impl<'a, 'b> Source for PathSource<'a, 'b> {
     }
 
     fn get(&self, ids: &[PackageId]) -> CargoResult<Vec<Package>> {
-        log!(5, "getting packages; ids={:?}", ids);
+        trace!("getting packages; ids={:?}", ids);
 
         Ok(self.packages.iter()
            .filter(|pkg| ids.iter().any(|id| pkg.get_package_id() == id))
@@ -262,7 +262,7 @@ impl<'a, 'b> Source for PathSource<'a, 'b> {
             warn!("{} {}", file.stat().map(|s| s.modified).unwrap_or(0), file.display());
             max = cmp::max(max, file.stat().map(|s| s.modified).unwrap_or(0));
         }
-        log!(5, "fingerprint {}: {}", self.path.display(), max);
+        trace!("fingerprint {}: {}", self.path.display(), max);
         Ok(max.to_string())
     }
 }
index ef41471cd0d997c2ac2f0750536497b3e462c9cf..a613ddbcfef917fe812744f58676f0bb1375f401 100644 (file)
@@ -453,7 +453,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> {
         // git reset --hard origin/master
         let reference = "refs/remotes/origin/master";
         let oid = try!(repo.refname_to_id(reference));
-        log!(5, "[{}] updating to rev {}", self.source_id, oid);
+        trace!("[{}] updating to rev {}", self.source_id, oid);
         let object = try!(repo.find_object(oid, None));
         try!(repo.reset(&object, git2::ResetType::Hard, None, None, None));
         self.updated = true;